
#include "pipehandles.h"

void pipe_listen_cb(struct __IOCPFILE* hListen, struct __IOCPFILE* hClient);
void pipe_read_cb(HIOCPFILE hObject, void* pUserData);
void pipe_write_cb(HIOCPFILE hObject, void* pUserData);
void pipe_signal_call(HIOCPFILE hSocket, DWORD dwEvent, DWORD dwError);

HIOCPFILE pipe_listen(HIOCPBASE hIocp)
{
    HIOCPFILE hPipe = fileio_create(hIocp, NULL, IOTYPE_PIPE);
    fileio_setcb(hPipe, pipe_read_cb, pipe_write_cb, pipe_signal_call, NULL);
    fileio_listen(hPipe, (SOCKADDR_IN*)PIPE_NAME, pipe_listen_cb);
    return hPipe;
}

void pipe_listen_close(HIOCPFILE hPipe)
{
    fileio_close(hPipe, 0);
}

void pipe_listen_cb(struct __IOCPFILE* hListen, struct __IOCPFILE* hClient)
{
    fileio_enable_read(hClient, TRUE);

    HIOCPFILE hPipe = fileio_create(fileio_get_iobase(hClient), NULL, IOTYPE_PIPE);
    fileio_setcb(hPipe, pipe_read_cb, pipe_write_cb, pipe_signal_call, NULL);
    fileio_listen(hPipe, (SOCKADDR_IN*)PIPE_NAME, pipe_listen_cb);
}

void pipe_read_cb(HIOCPFILE hObject, void* pUserData)
{

}

void pipe_write_cb(HIOCPFILE hObject, void* pUserData)
{

}

void pipe_signal_call(HIOCPFILE hSocket, DWORD dwEvent, DWORD dwError)
{

}
